const fs = require('fs');


const userRouter = (app)=>{
  fs.readdirSync(__dirname).forEach(file => {
      if( file !== 'index.js' ){
        const router = require(`./${file}`);
        app.use(router.routes())
        app.use(router.allowedMethods());   //    路由中间件
      }
  });
}
module.exports = userRouter;



// const fs = require('fs');
// //动态加载路由
//
// const useRoutes = function(app){
//   fs.readdirSync(__dirname).forEach(file =>{  //遍历文件夹
//     if(file ==='01_less.html') return;
//     const router = require(`./${file}`);  //动态加载路由
//     app.use(router.routes());
//     app.use(router.allowedMethods());
//   })
// }
//
// module.exports = useRoutes;